[chromium-binary-size] Add Makefile. Bug: 1319718 Change-Id: I700ba33f9d95ab9498876c8ce6a9972b14fa51ec
diff --git a/README.md b/README.md index 5911864..d162d73 100644 --- a/README.md +++ b/README.md
@@ -42,25 +42,26 @@ ### Web Plugin Development +Run the commands below in web/. + For running Java unit tests execute: - bazel test --test_output=all //plugins/chromium-binary-size:chromium-binary-size_tests + make test_java For running TypeScript unit tests execute: - bazel test --test_output=all //plugins/chromium-binary-size/web:karma_test + make test For checking or fixing eslint formatter problems run: - bazel test //plugins/chromium-binary-size/web:lint_test - bazel run //plugins/chromium-binary-size/web:lint_bin -- --fix "$(pwd)/plugins/chromium-binary-size/web" + make lint_test + make lint_fix For testing the plugin with [Gerrit FE Dev Helper](https://gerrit.googlesource.com/gerrit-fe-dev-helper/) -build the JavaScript bundle and copy it to the `plugins/chromium-binary-size` folder: +the command below builds the JavaScript bundle and copies it to the `plugins/chromium-binary-size` folder: - bazel build //plugins/chromium-binary-size/web:chromium-binary-size - cp -f bazel-bin/plugins/chromium-binary-size/web/chromium-binary-size.js plugins/chromium-binary-size + make build and let the Dev Helper redirect from `.+/plugins/chromium-binary-size/static/chromium-binary-size.js` to `http://localhost:8081/plugins_/plugins/chromium-binary-size.js`.
diff --git a/web/Makefile b/web/Makefile new file mode 100644 index 0000000..cbb4f81 --- /dev/null +++ b/web/Makefile
@@ -0,0 +1,21 @@ +# Copyright 2022 The Chromium Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +.PHONY: test + +test: + bazel test --test_output=all //plugins/chromium-binary-size/web:karma_test + +test_java: + bazel test --test_output=all //plugins/chromium-binary-size:chromium-binary-size_tests + +lint_test: + bazel test //plugins/chromium-binary-size/web:lint_test + +lint_fix: + bazel run //plugins/chromium-binary-size/web:lint_bin -- --fix "./" + +build: + bazel build //plugins/chromium-binary-size/web:chromium-binary-size && \ + cp -f ../../../bazel-bin/plugins/chromium-binary-size/web/chromium-binary-size.js ../
diff --git a/web/chromium-binary-size.ts b/web/chromium-binary-size.ts index 13c016b..246e856 100644 --- a/web/chromium-binary-size.ts +++ b/web/chromium-binary-size.ts
@@ -220,7 +220,7 @@ await this.scheduleBuild( changeNumber, Object.keys(changeInfo.revisions || {}).length, - repo, + repo ); return {shouldReload: true}; }, @@ -383,7 +383,9 @@ 'startTime', 'endTime', 'output.properties.fields.binarySizePlugin', - ].map(f => `builds.*.${f}`).join(','); + ] + .map(f => `builds.*.${f}`) + .join(','); const searchResponses = await Promise.all( patchPredicates.map(patchPredicate => @@ -449,10 +451,11 @@ revisions.push(change.revisions[revision]); } } - revisions.sort((a, b) => { - // Reverse sort. - return (b._number as number) - (a._number as number); - }); + revisions.sort( + (a, b) => + // Reverse sort. + (b._number as number) - (a._number as number) + ); const patchNums: number[] = []; for (let i = 0; i < revisions.length; i++) { if (i === 0 && change.status === ChangeStatus.MERGED) { @@ -475,7 +478,11 @@ return patchNums; } - private async scheduleBuild(change: number, patchset: number, project: string) { + private async scheduleBuild( + change: number, + patchset: number, + project: string + ) { try { const bb = new (window as any).buildbucket.BuildbucketV2Client( this.buildbucketHost
diff --git a/web/chromium-binary-size_test.ts b/web/chromium-binary-size_test.ts index 1421b41..6a2e513 100644 --- a/web/chromium-binary-size_test.ts +++ b/web/chromium-binary-size_test.ts
@@ -166,19 +166,19 @@ test('getCheckRunStatus', () => { assert.strictEqual( fetcher.getCheckRunStatus({} as BuildbucketBuild), - RunStatus.RUNNABLE, + RunStatus.RUNNABLE ); assert.strictEqual( fetcher.getCheckRunStatus({status: 'SCHEDULED'} as BuildbucketBuild), - 'SCHEDULED', + 'SCHEDULED' ); assert.strictEqual( fetcher.getCheckRunStatus({status: 'STARTED'} as BuildbucketBuild), - RunStatus.RUNNING, + RunStatus.RUNNING ); assert.strictEqual( fetcher.getCheckRunStatus({status: 'FAILURE'} as BuildbucketBuild), - RunStatus.COMPLETED, + RunStatus.COMPLETED ); }); @@ -207,25 +207,25 @@ fetcher.getCheckResultCategory({status: 'SUCCESS'} as BuildbucketBuild, [ {allowed: true} as ChromiumBinarySizeListing, ]), - Category.INFO, + Category.INFO ); assert.strictEqual( fetcher.getCheckResultCategory({status: 'SUCCESS'} as BuildbucketBuild, [ {allowed: false} as ChromiumBinarySizeListing, ]), - Category.WARNING, + Category.WARNING ); assert.strictEqual( fetcher.getCheckResultCategory({status: 'FAILURE'} as BuildbucketBuild, [ {allowed: true} as ChromiumBinarySizeListing, ]), - Category.INFO, + Category.INFO ); assert.strictEqual( fetcher.getCheckResultCategory({status: 'FAILURE'} as BuildbucketBuild, [ {allowed: false} as ChromiumBinarySizeListing, ]), - Category.ERROR, + Category.ERROR ); }); @@ -591,7 +591,11 @@ properties: { binary_size_plugin: { listings: [ - {name: 'Android Binary Size', delta: '+999 bytes', allowed: true}, + { + name: 'Android Binary Size', + delta: '+999 bytes', + allowed: true, + }, {name: 'foo', allowed: false}, {name: 'baz', allowed: false}, ], @@ -608,10 +612,12 @@ assert.strictEqual(run.results!.length, 1); assert.strictEqual( run.results![0].summary, - 'Android Binary Size changed by +999 bytes. 2 of 3 checks failed.'); + 'Android Binary Size changed by +999 bytes. 2 of 3 checks failed.' + ); assert.strictEqual( run.results![0].message, - 'Failing checks: foo, baz. Expand to view more.'); + 'Failing checks: foo, baz. Expand to view more.' + ); // All listings passed. stubSearch( @@ -625,7 +631,11 @@ properties: { binary_size_plugin: { listings: [ - {name: 'Android Binary Size', delta: '+2 bytes', allowed: true}, + { + name: 'Android Binary Size', + delta: '+2 bytes', + allowed: true, + }, {name: 'foo', allowed: true}, ], }, @@ -641,9 +651,8 @@ assert.strictEqual(run.results!.length, 1); assert.strictEqual( run.results![0].summary, - 'Android Binary Size changed by +2 bytes. All checks passed.'); - assert.strictEqual( - run.results![0].message, - 'Expand to view more.'); + 'Android Binary Size changed by +2 bytes. All checks passed.' + ); + assert.strictEqual(run.results![0].message, 'Expand to view more.'); }); });